Ext.BLANK_IMAGE_URL = "js/ext/resources/images/default/s.gif";
Ext.namespace("GMC");
GMC.portal = {
	init: function(){		
		new Ext.Viewport({
    		layout: "border",
    		border : false, 
    		items: [{
		    	id: "NorthPanel",
		        region: "north",
	    		split:false,
		        height: 72,
		        autoLoad: "header.jsp"
		    }, {
		    	id: "WestPanel",
		    	border:true,
		    	split:false,
		    	xtype: "billTreePanel",
                root: new Ext.tree.AsyncTreeNode({id: "root", text: "", 
					expanded : true		//自动展开节点
				}),
				listeners: {
		        	"click": function(node){
		        		if (node.isLeaf())
		        			Ext.getCmp("CenterPanel").setIframe(node);
		        	}
		        },
				loader: new Ext.ux.MenuTreeLoader({url:"system!qurCurrentPersonMenu.action"})
		    }, {
		    	id: "CenterPanel",
		    	split:false,
		        region: "center",
		        layout: "fit",		
		        xtype: "gmc_desktoppanel"
		    }]
		});
		Ext.QuickTips.init();
	}
};
var mystore={
	organStore:new Ext.data.JsonStore({
	    	root:"data",
	    	totalProperty: "total",
			fields: ["id","name", "type", "contact", "phone", "postal","address","area","supperId","post"],
			url: "organization!listByParent.action"
	}),
	organTypeStore:new Ext.data.JsonStore({
		fields: ["id","text"],
		data:[{id:"H",text:"总行"},{id:"B",text:"分行"},{id:"S",text:"支行"},{id:"O",text:"分理处"}]
	})
};
function logout(){
	document.forms["logout_form"].submit();
}
function alertMsg(input){
	 Ext.Msg.show({
		 title:"警告",
		 msg:input,
		 buttons: Ext.Msg.OK,
		 animEl: "elId",
		icon:Ext.MessageBox.WARNING
	});
}
function editpwd(){
	new Ext.Window({
		id:"pwdedit",
		xtype:"form",
		layout:"form",
		title:"密码修改",
		width:270,
		height:150,
		modal:true,//屏蔽
		resizable : false,//不允许改变大小
		draggable : false,//不允许拖拽窗口
		labelWidth: 70,
	    bodyStyle:"padding:2px 5px 0",
		defaultType: "textfield",		
		items: [{
			id: "oldname",
	    	fieldLabel: "原始密码",
	    	inputType: 'password',
	    	anchor: "100%",
	    	vtype:'password',
	    	allowBlank: false,
	    	maxLength:20,
	    	listeners:{
	    		"change":function(e,nv){
	    			Ext.Ajax.request({
						clientValidation : true,
						params: {oldpwd:nv},
						url: "person!checkPwd.action",
						success: function(response, opts) {
							var d=eval("("+response.responseText+")");
							if(d.code == "1"){
								Ext.Msg.show({
								   title:"提示",
								   msg:d.data,
								   buttons:Ext.Msg.OK,
								   icon: Ext.MessageBox.INFO
								});
								e.setValue("");
							}
						}
			    	});
	    		}
	    	}
	    },{
	    	id: "newname",
    		fieldLabel: "新密码",
    		inputType: 'password',
    		anchor: "100%",
    		vtype:'password',
	    	allowBlank: false,
	    	maxLength:20
    	},{
    		id:"newrealy",
    		fieldLabel: "确认新密码",
			inputType: 'password',
			anchor: "100%",
			vtype:'password',
	    	allowBlank: false,
	    	maxLength:20,
	    	validator:function (val){
        		var newname = Ext.getCmp("newname").getValue();
        		if(newname!=val){
        			return "密码输入不一致!";
        		}
        		return true;
        	}
		}],
		buttonAlign:"center",
		buttons:[
		    {text:"保存",id:"save",handler: function(e){
		    	var old = !Ext.getCmp("oldname").isValid();
		    	var ne = !Ext.getCmp("newname").isValid();
		    	var ner = !Ext.getCmp("newrealy").isValid();
		    	if(old||ne||ner){
					Ext.Msg.show({
		              title:"警告",
		              msg: "验证不通过!",
		              buttons: Ext.Msg.OK,
		              animEl: "elId",
		              icon:Ext.MessageBox.WARNING
		            });
    				return;
				}
		    	Ext.Ajax.request({
					clientValidation : true,
					params: {"person.password":Ext.getCmp("newname").getValue()},
					url: "person!editPwd.action",
					success: function(response, opts) {
						var d=eval("("+response.responseText+")");
						Ext.Msg.show({
						   title:"提示",
						   msg:d.data,
						   buttons:Ext.Msg.OK,
						   icon: Ext.MessageBox.INFO
						});
						if(d.code == "0"){
							Ext.getCmp("pwdedit").close();
						}						
					}
		    	});
			}},{text:"取消", handler: function(){
				Ext.getCmp("pwdedit").close();
			}}]
		
	}).show();
}

/**
 * 系统参数读取
 */
var sys_store = {
	recordName:Ext.data.Record.create([
 		{name: 'id'},
 		{name: 'text'}
 	]),
	checkedStmtdate:null,//账单日多选
	init: function(){	
		this.allstore.load({callback:function(){
			//获取所有的系统参数
			var arraylist = null;
			//解析个性化区域类型
			sys_store.areaType.add(this.query("codetypeid","area_type",true,true).getRange());
			//解析账单日
			var list=this.query("codetypeid","stmtdate",true,true).getRange();
			var tempObj={};
			var templist=new Array();
			for(var i=0;i<list.length;i++){
				tempObj={};
				tempObj.boxLabel=list[i].data.text
					   .name=list[i].data.text
				templist.push(tempObj);
			}
			sys_store.checkStmtdate.items=templist;
			//账单日store
			sys_store.stmtdate.add(list);
			sys_store.seachStmtdate.add(list);
			sys_store.seachStmtdate.insert(0,new sys_store.recordName({id:'',text: '全部'}));
			
		}});
		Ext.QuickTips.init();
	},
	allstore:new Ext.data.JsonStore({
		root: "data",
		totalProperty: "total",
		fields: [{name:"id",mapping:"codetype"},{name:"text",mapping:"codename"},"codetypeid"],
		url: "systemUserCode!doSysStore.action"
	}),
	areaType:new Ext.data.JsonStore({			
		fields: ["id","text"]
	}),
	stmtdate:new Ext.data.JsonStore({			
		fields: ["id","text"]
	}),
	seachStmtdate:new Ext.data.JsonStore({			
		fields: ["id","text"]
	}),
	checkStmtdate:{
		id :"stmtdate",
		fieldLabel : "账单日",
		//anchor:"60%",
		width:280,
		name:"period_day_add",
		xtype:"checkboxgroup",
		listeners:{
			change:function(t,checkedList){
				sys_store.checkedStmtdate=checkedList;
			}
		}
	}
};
Ext.onReady(sys_store.init, sys_store);

